package com.neusoft.neuiotms.dcam.workflow.converter;

import java.util.Date;
import java.util.UUID;

import org.springframework.stereotype.Component;

import com.neusoft.bizcore.web.dto.AbstractConverter;
import com.neusoft.neuiotms.dcam.workflow.dto.RukuKJGoodsFileDTO;
import com.neusoft.neuiotms.dcam.workflow.model.RukuKJGoodsFile;

@Component
public class RukuKJGoodsFileConverter extends AbstractConverter<RukuKJGoodsFile, RukuKJGoodsFileDTO> {

    @Override
    public RukuKJGoodsFile toModel(final RukuKJGoodsFileDTO dto) {
        final RukuKJGoodsFile model;
        model = new RukuKJGoodsFile();
        model.setCode(UUID.randomUUID().toString());
        model.setName(dto.getName());
        model.setSpecification(dto.getSpecification());
        model.setDescription(dto.getDescription());
        model.setUpdateTime(new Date());
        model.setManagementOrgCode(dto.getManagementOrgCode());
        model.setManagementOrgName(dto.getManagementOrgName());
        model.setSpareTypeCode(dto.getSpareTypeCode());
        model.setSpareTypeName(dto.getSpareTypeName());
        model.setAssetCode(dto.getAssetCode());
        return model;
    }

    @Override
    public RukuKJGoodsFileDTO toDTO(final RukuKJGoodsFile model, final boolean forListView) {
        final RukuKJGoodsFileDTO dto = new RukuKJGoodsFileDTO();

        dto.setId(model.getId());
        dto.setCode(model.getCode());
        dto.setName(model.getName());
        dto.setSpecification(model.getSpecification());
        dto.setDescription(model.getDescription());
        dto.setCreateTime(model.getCreateTime());
        dto.setUpdateTime(model.getUpdateTime());
        dto.setManagementOrgCode(model.getManagementOrgCode());
        dto.setManagementOrgName(model.getManagementOrgName());
        dto.setSpareTypeCode(model.getSpareTypeCode());
        dto.setSpareTypeName(model.getSpareTypeName());
        return dto;
    }
}
